<!DOCTYPE html>
<html >
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联-商家后台管理系统</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SHOP_HOME_IMG')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('SHOP_HOME_IMG')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
 <!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->
  
  <!-- content start -->
  <div class="admin-content">
  <!-- 基本信息 start-->
  <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">订单列表</strong> / <small>订单详情</small></div>
    </div>
    <!--基本信息start -->
    <div class="am-g">
      <section class="am-panel am-panel-default">
        <header class="am-panel-hd">
          <h3 class="am-panel-title">基本信息</h3>
        </header>
        <div class="am-panel-bd">
                  <table class="am-table am-table-bd am-table-striped admin-content-table">
                    <tbody>
                    <tr> <td align="right">收货人：</td><td>{$order['consignee']}</td>
                    <td align="right">联系方式:</td><td>{$order['mobile']} </td>
                    </tr>
                    <tr>
                    <td align="right">收货地址:</td><td>{$order['province']}{$order['city']}{$order['district']}{$order['address']}</td>
                    </tr>
                    <tr>
                    <td align="right">经销商信息:</td> <td>{$shopinfo}</td>
                    </tr>
                     <tr>
                    <td align="right">供应商信息:</td> <td>{$supperinfo['companyname']}&nbsp &nbsp {$supperinfo['contactname']}  &nbsp &nbsp {$supperinfo['mobile']}</td>
                    </tr>
                     
                    </tbody>
                  </table>
         
        </div>
    </section>
    </div>
    <!--基本信息end -->
    <!--s商品start -->
     <div class="am-g">
      <section class="am-panel am-panel-default">
            <header class="am-panel-hd">
              <h3 class="am-panel-title">商品信息</h3>
            </header>
            <div class="am-panel-bd">
                      <table class="am-table am-table-bd am-table-striped admin-content-table">
                        <thead>
                          <td>订单编号</td>
                          <td>商品名称</td>
                          <td>规格型号</td>
                          <td>零售价</td>
                          <td>活动价</td>
                          <td>供货价</td>
                          <td>数量</td>
                          <td>商品总价</td>
                        </thead>
                        <tbody>
                        <td>{$order['order_sn']}</td>
                        <td>{$order['itemname']}</td>
                        <td>{$order['specvale']}</td>
                        <td>{$order['price']}</td>
                        <td>{$order['activprice']}</td>
                        <td>{$order['supperprice']}</td>
                        <td>{$order['number']}</td>
                        <td>{$order['order_amount']}</td>
                        </tbody>
                      </table>        
            </div>
            <input name="orderid" type="hidden" value="{$order['orderid']}"/> 
    </section>
    </div>
    <!--商品信息end-->
    <!-- 订单状态-->
       <div class="am-g">
      <section class="am-panel am-panel-default">
        <header class="am-panel-hd">
          <h3 class="am-panel-title">订单状态</h3>
        </header>
        <div class=" col-lg-12">
          <span>订单可执行操作：</span> 
          <switch name="orderstatus">
          <case value="0">
           <button type="button" class="am-btn am-btn-success  orderstatus" value="1">确认订单</button>
           <button type="button" class="am-btn am-btn-default  orderstatus" value="2">取消订单</button>
           </case>
           <case value="1">
                 <button type="button" class="am-btn am-btn-success " >订单已确认</button>
                 <button type="button" class="am-btn am-btn-default  orderstatus" value="3">付款</button>
                  <button type="button" class="am-btn am-btn-default  orderstatus" value="2">取消订单</button>
           </case>
           <case value="3">
                 <button type="button" class="am-btn am-btn-success   ">订单已确认</button>
                 <button type="button" class="am-btn am-btn-success   ">订单已付款</button>
                 <button type="button" class="am-btn am-btn-default  orderstatus" value="6">配货</button>
                  <button type="button" class="am-btn am-btn-default  orderstatus" value="2">取消订单</button>
           </case>
           <case value="8">
                 <button type="button" class="am-btn am-btn-success  ">订单已确认</button>
                 <button type="button" class="am-btn am-btn-success  ">订单已付款</button>
                 <button type="button" class="am-btn am-btn-success ">已发货</button>
           </case>
            <case value="9">
                <button type="button" class="am-btn am-btn-success  ">订单已确认</button>
                <button type="button" class="am-btn am-btn-success  ">订单已付款</button>
                 <button type="button" class="am-btn am-btn-success">已发货</button>
                <button type="button" class="am-btn am-btn-success  ">已收货</button>
           </case>
            <case value="2">

                <button type="button" class="am-btn am-btn-danger "> 已取消</button>
           </case>
           <case value="6">
                <button type="button" class="am-btn am-btn-success  ">订单已确认</button>
                <button type="button" class="am-btn am-btn-success  ">订单已付款</button>
                <button type="button" class="am-btn am-btn-success ">配货中</button>
           </case>
          </switch>
        </div>
    </section>
  </div>  
      <div class="am-g">
         <div class="am-u-sm-12">
          <table class="am-table am-table-bordered am-table-striped am-table-compact orderlog">
                <thead>
                  <tr>
                      <th>操作者</th>
                      <th>操作时间</th>
                      <th>订单状态</th>
                      <th>付款状态</th>
                      <th>发货状态</th>
                      <th>备注</th>
                  </tr>
            </thead>
            <tbody>
              

            </tbody>
            
          </table>
         </div>
      </div>
  </div>







    </div>

  <!-- content end -->

  <!--footer start-->
<script src="{:C('ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>
<!-- footer end -->
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>
<script type="text/javascript">
  $(function(){
    $('.orderstatus').click(function(){
      $status=$(this).attr('value'); //需要更改的订单状态
      $orderid=$("input[name='orderid']").val();
      if (!$status || !$orderid) {return false; };
       $.ajax({
        type:"POST",
        url:"{:U(orderStatus)}",
        data:{"status":$status,"orderid":$orderid},
        dataType:"text",
        success:function(message){
            if (message) {
              window.location.reload();
            }else{
              alert('系统繁忙,操作失败');
            }
        }
       });
    });
  })
  /* 通过ajax 动态调用订单操作记录*/
  $(function(){
    var $orderid=$("input[name='orderid']").val();
    $.ajax({
        type:"POST",
        url:"{:U('orderAction')}",
        data:{"orderid":$orderid},
        dataType:"json",
        success:function(message){
          if (message.status) 
            {
               var $logs=message.logs;
               var  $tbody=$('<tbody></tbody>');
               var $string='';
               $.each($logs,function(key,log){
                $string+="<tr>";
                $string+="<td>"+log.action_user+"</td>";
                $string+="<td>"+log.edittime+"</td>";
                var $status=parseInt(log.status);
                switch($status)
                {
                    case 0:
                      $string+="<td>未确认</td>";
                      $string+="<td>未付款</td>";
                      $string+="<td>未发货</td>";
                      $string+="<td>"+log.action_note+"</td>";
                      break;
                    case 2:
                      $string+="<td>未确认</td>";
                      $string+="<td>未付款</td>";
                      $string+="<td>未发货</td>";
                      $string+="<td>订单已取消</td>";
                      break;
                      case 1:
                      $string+="<td>已确认</td>";
                      $string+="<td>未付款</td>";
                      $string+="<td>未发货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 3:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>未发货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 6:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>配货中</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 8:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>已发货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                      case 9:
                      $string+="<td>已确认</td>";
                      $string+="<td>已付款</td>";
                      $string+="<td>已收货</td>";
                       $string+="<td>"+log.action_note+"</td>";
                      break;
                
                } 
                
                
                $string+="</tr>"; 
               });
               $tbody.append($string);
               $($tbody).replaceAll(".orderlog tbody");

            }else{
                return '';
            }
        }
    })
  })
</script>
</body>
</html>